<%= render :partial => "apo/navigation" %>

<div id="containerBody">

<% if session[:user].admin? or @member == session[:user] %>
	<div style="margin-left: 4em; margin-bottom: 1em">
		<i>
			<%= link_to "edit information", :action => "edit", :id => @member %>
			<% if session[:user].admin? %>
				<br><%= link_to "refresh data", :action => "refresh", :id => @member %>
			<% end %>
		</i>
	</div>
<% end %>
<div class="container memberInfoContainer" style="margin-left: 4em;">

	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL"><b>Personal Information</b></div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">Name:</div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">Birthday:</div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">Username:</div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">Email:</div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">Phone Number:</div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">Screen Name:</div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">Campus Address:</div>
	</div>
	<% if @member.school_address_two != "" %>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">&nbsp;</div>
	</div>
	<% end %>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">&nbsp;</div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">Permanent Address:</div>
	</div>
	<% if @member.permanent_address_two != "" %>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">&nbsp;</div>
	</div>
	<% end %>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">&nbsp;</div>
	</div>

</div>

<div class="container memberInfoContainer">

	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">&nbsp;</div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL"><%=h @member.full_name %></div>
	</div>
	<div class="cellRow">
		<% if  (@member.birthday != nil) %>
			<div class="cellBlock cellBlockNoBorderL"><%=h @member.birthday.strftime("%m/%d/%y") %></div>
		<% else %>
		    &nbsp;
		<% end %>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL"><%=h @member.username %></div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL"><%=h @member.email %>&nbsp;</div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL"><%=h @member.phone_number %>&nbsp;</div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL"><%=h @member.screen_name %>&nbsp;</div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL"><%=h @member.school_address_one %>&nbsp;</div>
	</div>
	<% if @member.school_address_two != "" %>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL"><%=h @member.school_address_two %>&nbsp;</div>
	</div>
	<% end %>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">
		    <%=h @member.school_city %><%= @member.school_city != ""?", ":"" %>
		    <%=h @member.school_state %> <%=h @member.school_zip %>&nbsp;
	    </div>
	</div>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL"><%=h @member.permanent_address_one %>&nbsp;</div>
	</div>
	<% if @member.permanent_address_two != "" %>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL"><%=h @member.permanent_address_two %>&nbsp;</div>
	</div>
	<% end %>
	<div class="cellRow">
		<div class="cellBlock cellBlockNoBorderL">
		    <%=h @member.permanent_city %><%= @member.permanent_city != ""?", ":"" %>
		    <%=h @member.permanent_state %> <%=h @member.permanent_zip %>&nbsp;
	    </div>
	</div>

</div>

<div class="container memberInfoContainer">

	<div class="cellRow cellBlockNoBorderL">
		<div class="cellBlock"><b>APO Information</b></div>
	</div>
	<div class="cellRow cellBlockNoBorderL">
		<div class="cellBlock">Pledge Class:</div>
	</div>
	<div class="cellRow cellBlockNoBorderL">
		<div class="cellBlock">Status:</div>
	</div>
	<div class="cellRow cellBlockNoBorderL">
		<div class="cellBlock">Office:</div>
	</div>
	<div class="cellRow cellBlockNoBorderL">
		<div class="cellBlock">Committee:</div>
	</div>
	<% if session[:user].admin? %>
	  <div class="cellRow cellBlockNoBorderL">
	    <div class="cellBlock">Last refresh:</div>
	  </div>
	  <div class="cellRow cellBlockNoBorderL">
	    <div class="cellBlock">Admin:</div>
	  </div>
	<% end %>

</div>

<div class="container memberInfoContainer">

	<div class="cellRow cellBlockNoBorderL">
		<div class="cellBlock">&nbsp;</div>
	</div>
	<div class="cellRow cellBlockNoBorderL">
		<div class="cellBlock"><%=h @member.pledge_class %>&nbsp;</div>
	</div>
	<div class="cellRow cellBlockNoBorderL">
		<div class="cellBlock"><%=h @member.status %>&nbsp;</div>
	</div>
	<div class="cellRow cellBlockNoBorderL">
		<div class="cellBlock"><%=h @member.office.nil? ? "none" : @member.office %></div>
	</div>
	<div class="cellRow cellBlockNoBorderL">
		<div class="cellBlock"><%=h @committee.nil? ? "none" : link_to(@committee.name, {:controller => :events, :action => :show, :id => @committee}) %></div>
	</div>
	<% if session[:user].admin? %>
	  <div class="cellRow cellBlockNoBorderL">
	    <div class="cellBlock"><%= @member.updated_at %></div>
	  </div>
	  <div class="cellRow cellBlockNoBorderL">
	    <div class="cellBlock"><%= @member.admin ? "Yes" : "No" %></div>
	  </div>
	<% end %>

</div>

<div id="eventBottomDiv" style="text-align: center; width: 100%; margin-top: 0.1em;">
</div>

<div class="achievementLabel">Potential Achievement This Semester</div>

<div class="container progressContainer showContainer">

	<div class="cellRow cellRowHeader">
		<div class="cellBlock">Service Points</div>
		<div class="cellBlock">Leadership Points</div>
		<div class="cellBlock">Fellowship Points</div>
		<div class="cellBlock">Meeting Points</div>
		<div class="cellBlock">Fundraising Points</div>
		<div class="cellBlock">Dues</div>
	</div>

	<div class="cellRow cellRow1">
		<% if (@member.status == "Active" or @member.status == "New Active" or @member.status == "Associate" or @member.status == "Probate")%>
			<div class="cellBlock"><%=h @memberData["service"]["potential"] %>/<%= @memberData["total_required_hours"] %></div>
			<div class="cellBlock"><%=h @memberData["leadership"]["potential"].to_i %>/<%= Member.active_leaderships_requirement %></div>
			<div class="cellBlock"><%=h @memberData["fellowship"]["potential"].to_i %>/<%= Member.active_fellowships_requirement %></div>
			<div class="cellBlock"><%=h @memberData["meeting"]["potential"].to_i %>/<%= Member.active_meetings_requirement %></div>
			<div class="cellBlock"><%=h @memberData["fundraiser"]["potential"].to_i %>/<%= Member.active_fundraisers_requirement %></div>
			<div class="cellBlock"><%=h @memberData["dues"].to_i %>/<%= Member.active_dues_requirement %></div>

		<% elsif(@member.status == "Pledge" or @member.status == "Neophyte") %>
			<div class="cellBlock"><%=h @memberData["service"]["potential"] %>/<%= @memberData["total_required_hours"] %></div>
			<div class="cellBlock"><%=h @memberData["leadership"]["potential"].to_i %>/<%= Member.pledge_leaderships_requirement %></div>
			<div class="cellBlock"><%=h @memberData["fellowship"]["potential"].to_i %>/<%= Member.pledge_fellowships_requirement %></div>
			<div class="cellBlock"><%=h @memberData["meeting"]["potential"].to_i %>/<%= Member.pledge_meetings_requirement %></div>
			<div class="cellBlock"><%=h @memberData["fundraiser"]["potential"].to_i %>/<%= Member.pledge_fundraisers_requirement %></div>
			<div class="cellBlock"><%=h @memberData["dues"].to_i %>/<%= Member.pledge_dues_requirement %></div>

		<% else %>
			<div class="cellBlock">&nbsp;</div>
			<div class="cellBlock">&nbsp;</div>
			<div class="cellBlock">&nbsp;</div>
			<div class="cellBlock">&nbsp;</div>
			<div class="cellBlock">&nbsp;</div>
			<div class="cellBlock">&nbsp;</div>
		<% end %>
	</div>

</div>

<div class="achievementLabel">Actual Achievement This Semester</div>

<div class="container progressContainer showContainer">

	<div class="cellRow cellRowHeader">
		<div class="cellBlock">Service Points</div>
		<div class="cellBlock">Leadership Points</div>
		<div class="cellBlock">Fellowship Points</div>
		<div class="cellBlock">Meeting Points</div>
		<div class="cellBlock">Fundraising Points</div>
		<div class="cellBlock">Dues</div>
	</div>

	<div class="cellRow cellRow1">
		<% if (@member.status == "Active" or @member.status == "New Active" or @member.status == "Associate" or @member.status == "Probate")%>
			<div class="cellBlock"><%=h @memberData["service"]["actual"] %>/<%= @memberData["total_required_hours"] %></div>
			<div class="cellBlock"><%=h @memberData["leadership"]["actual"].to_i %>/<%= Member.active_leaderships_requirement %></div>
			<div class="cellBlock"><%=h @memberData["fellowship"]["actual"].to_i %>/<%= Member.active_fellowships_requirement %></div>
			<div class="cellBlock"><%=h @memberData["meeting"]["actual"].to_i %>/<%= Member.active_meetings_requirement %></div>
			<div class="cellBlock"><%=h @memberData["fundraiser"]["actual"].to_i %>/<%= Member.active_fundraisers_requirement %></div>
			<div class="cellBlock"><%=h @memberData["dues"].to_i %>/<%= Member.active_dues_requirement %></div>

		<% elsif(@member.status == "Pledge" or @member.status == "Neophyte") %>
			<div class="cellBlock"><%=h @memberData["service"]["actual"] %>/<%= @memberData["total_required_hours"] %></div>
			<div class="cellBlock"><%=h @memberData["leadership"]["actual"].to_i %>/<%= Member.pledge_leaderships_requirement %></div>
			<div class="cellBlock"><%=h @memberData["fellowship"]["actual"].to_i %>/<%= Member.pledge_fellowships_requirement %></div>
			<div class="cellBlock"><%=h @memberData["meeting"]["actual"].to_i %>/<%= Member.pledge_meetings_requirement %></div>
			<div class="cellBlock"><%=h @memberData["fundraiser"]["actual"].to_i %>/<%= Member.pledge_fundraisers_requirement %></div>
			<div class="cellBlock"><%=h @memberData["dues"].to_i %>/<%= Member.pledge_dues_requirement %></div>

		<% else %>
			<div class="cellBlock">&nbsp;</div>
			<div class="cellBlock">&nbsp;</div>
			<div class="cellBlock">&nbsp;</div>
			<div class="cellBlock">&nbsp;</div>
			<div class="cellBlock">&nbsp;</div>
			<div class="cellBlock">&nbsp;</div>
		<% end %>
	</div>

</div>

<div class="achievementLabel">Events Attended This Semester</div>

<div class="container showContainer" style="width: 29em; margin-left: 15em;">

	<div class="cellRow cellRowHeader">
		<div class="cellBlock">Event Name</div>
		<div class="cellBlock">Date</div>
		<div class="cellBlock">Hours</div>
		<div class="cellBlock">MIC</div>
		<div class="cellBlock">Driver</div>
		<div class="cellBlock">Event Type</div>
		<!--<% if session[:user].admin %>
			<div class="cellBlock"></div>
		<% end %>-->
	</div>

  <% counter = 0 %>
	<% @events.each do |event| %>
		<% currentAR = @member.attendance_records.find_by_event_id(event) %>
		<% if event.approved and currentAR.attended %>
			<div class="cellRow cellRow<%= counter%2==0?1:2 %>">
				<div class="cellBlock">
					<%= link_to h(event.name), :controller => "events", :action => "show", :id => event %>
				</div>
				<div class="cellBlock" style="text-align: center;">
					<%=h event.date.strftime("%m/%d/%y").center(0) %>
				</div>
				<div class="cellBlock" style="text-align: center;">
					<%=h event.hours + Member.get_adjustment_hours(@member.id, event.id) %>
				</div>
				<div class="cellBlock" style="text-align: center;"><%=h event.mic_id == @member.id ? "Yes" : "No" %></div>
				<div class="cellBlock" style="text-align: center;"><%=h currentAR.driver ? "Yes" : "No" %></div>
				<div class="cellBlock" style="text-align: center;"><%=h event.event_type %></div>
				<!--<% if session[:user].admin %>
					<div class="cellBlock" style="text-align: center;">
						<%= link_to "edit", :controller => "events", :action => "edit", :id => event.id %>
					</div>
				<% end %>-->
			</div>
	    <% counter = counter + 1 %>
		<% end %>
	<% end %>

</div>

<div class="achievementLabel">Events Not Attended This Semester</div>

<div class="container showContainer" style="width: 29em; margin-left: 15em;">

	<div class="cellRow cellRowHeader">
		<div class="cellBlock">Event Name</div>
		<div class="cellBlock">Date</div>
		<div class="cellBlock">Hours</div>
		<div class="cellBlock">MIC</div>
		<div class="cellBlock">Driver</div>
		<div class="cellBlock">Event Type</div>
	</div>

  <% counter = 0 %>
	<% @events.each do |event| %>
		<% currentAR = @member.attendance_records.find_by_event_id(event) %>
		<% if event.event_type != "Committee" and event.approved and !currentAR.attended %>
			<div class="cellRow cellRow<%= counter%2==0?1:2 %>">
				<div class="cellBlock">
					<%= link_to h(event.name), :controller => "events", :action => "show", :id => event %>
				</div>
				<div class="cellBlock" style="text-align: center;">
					<%=h event.date.strftime("%m/%d/%y").center(0) %>
				</div>
				<div class="cellBlock" style="text-align: center;">
					<%=h event.hours + Member.get_adjustment_hours(@member.id, event.id) %>
				</div>
				<div class="cellBlock" style="text-align: center;"><%=h event.mic_id == @member.id ? "Yes" : "No" %></div>
				<div class="cellBlock" style="text-align: center;"><%=h currentAR.driver ? "Yes" : "No" %></div>
				<div class="cellBlock" style="text-align: center;"><%=h event.event_type %></div>
			</div>
	    <% counter = counter + 1 %>
		<% end %>
	<% end %>

</div>

<div class="achievementLabel">Events Potentially Attended or Attending This Semester</div>

<div class="container showContainer" style="width: 29em; margin-left: 15em;">

	<div class="cellRow cellRowHeader">
		<div class="cellBlock">Event Name</div>
		<div class="cellBlock">Date</div>
		<div class="cellBlock">Hours</div>
		<div class="cellBlock">MIC</div>
		<div class="cellBlock">Driver</div>
		<div class="cellBlock">Event Type</div>
	</div>
  <% counter = 0 %>
	<% @events.each do |event| %>
		<% if !event.approved %>
			<div class="cellRow cellRow<%= counter%2==0?1:2 %>">
				<div class="cellBlock">
					<%= link_to h(event.name), :controller => "events", :action => "show", :id => event %>
				</div>
				<div class="cellBlock" style="text-align: center;">
					<%=h event.date.strftime("%m/%d/%y").center(0) %>
				</div>
				<div class="cellBlock" style="text-align: center;">
					<%=h event.hours + Member.get_adjustment_hours(@member.id, event.id) %>
				</div>
				<div class="cellBlock" style="text-align: center;"><%=h event.mic_id == @member.id ? "Yes" : "No" %></div>
				<div class="cellBlock" style="text-align: center;"><%=h @member.attendance_records.find_by_event_id(event).driver ? "Yes" : "No" %></div>
				<div class="cellBlock" style="text-align: center;"><%=h event.event_type %></div>
			</div>
	    <% counter = counter + 1 %>
    <% end %>
	<% end %>
</div>



<!--
<h3 align="center"> Total Lifetime Achievement </h3>

<table class="activation_progress" align="center">
	<tr>
		<td align="center"> Semester</div>
		<td align="center"> Service Hours</div>
		<td align="center"> Fellowships</div>
		<td align="center"> LDC's</div>
		<td align="center"> Fundraisers</div>
		<td align="center"> Office Hours</div>
		<td align="center"> Ceremonies</div>
		<td align="center"> Dues</div>
		<td align="center"> Meetings</div>
	</tr>
	<tr>
		<td align="center"> <%#=h @member.career_service_hours %></div>
		<td align="center"> <%#=h @member.career_fellowships %></div>
		<td align="center"> <%#=h @member.career_leaderships %></div>
		<td align="center"> <%#=h @member.career_fundraisers %></div>
		<td align="center"> <%#=h @member.career_office_hours %></div>
		<td align="center"> <%#=h @member.career_ceremonies %></div>
		<td align="center"> <%#=h @member.career_sets_of_dues_paid %></div>
		<%# if (@member.status == "Pledge")%>
			<td class="activation_progress"> <%#=h @member.pledge_meetings_attended %></div>
		<%# else %>
			<td class="activation_progress"> <%#=h @member.active_meetings_attended %></div>
		<%# end %>
		<%# if session[:user].admin?%>
			<td align="center"> <%#= link_to "edit" , :action => "edit" , :id => @member %></div>
		<%# end %>
	</tr>

</table>

<%# links each semester to a page displaying a list of all events attended (service, leadership, fellowship, etc) %>

-->

</div>
